package com.unitd.modules.configcenter.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.unitd.comm.entity.DataEntity;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * @desc 应用配置信息管理表表对应实体对象
 * @filename AppConfigs.java
 * @copyright www.unitd.com
 * @author Hudan
 * @version 1.0
 * @date  2018-01-30
 */
@Table(name = "app_configs")
public class AppConfigs extends DataEntity {

	/** 绑定的应用ID串 */
	@Column(name = "app_ids")
	private String appIds;
	/** 配置所对应的环境 */
	@Column(name = "env")
	private String env;
	/** 版本号 */
	@Column(name = "version")
	private String version;
	/** 配置名 */
	@Column(name = "name")
	private String name;
	/** 类型(1:文件，2:配置项，3：JSON) */
	@Column(name = "type")
	private Short type;
	/** 配置内容 */
	@Column(name = "contents")
	private String contents;
	/** created_at */
	@Column(name = "created_at")
	private Date createdAt;
	/** created_by */
	@Column(name = "created_by")
	private String createdBy;
	/** updated_at */
	@Column(name = "updated_at")
	private Date updatedAt;
	/** updated_by */
	@Column(name = "updated_by")
	private String updatedBy;

	/* ************************** 与数据库字段不直接关联而是对应外键对象或数据处理的字段 ************************** */
	/** 需要查询的绑定的应用ID */
	@Transient
	private String appId;
	/** 是否为全局配置 */
	@Transient
	private Boolean global = false;
	/** 应用名称 */
	@Transient
	private String appName;

	public AppConfigs() {
		super();
	}

	public AppConfigs(String id){
		super(id);
	}

	public AppConfigs(String id, String appIds, String env, String version, String name, Short type, String contents, Date createdAt, String createdBy, Date updatedAt, String updatedBy){
		this.id = id;
		this.appIds = appIds;
		this.env = env;
		this.version = version;
		this.name = name;
		this.type = type;
		this.contents = contents;
		this.createdAt = createdAt;
		this.createdBy = createdBy;
		this.updatedAt = updatedAt;
		this.updatedBy = updatedBy;
	}

	public String getAppIds() {
		return appIds;
	}
	public void setAppIds(String appIds) {
		this.appIds = appIds;
	}
	public String getEnv() {
		return env;
	}
	public void setEnv(String env) {
		this.env = env;
	}
	public String getVersion() {
		return version;
	}
	public void setVersion(String version) {
		this.version = version;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Short getType() {
		return type;
	}
	public void setType(Short type) {
		this.type = type;
	}
	public String getContents() {
		return contents;
	}
	public void setContents(String contents) {
		this.contents = contents;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getCreatedAt() {
		return createdAt;
	}
	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}
	public String getCreatedBy() {
		return createdBy;
	}
	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getUpdatedAt() {
		return updatedAt;
	}
	public void setUpdatedAt(Date updatedAt) {
		this.updatedAt = updatedAt;
	}
	public String getUpdatedBy() {
		return updatedBy;
	}
	public void setUpdatedBy(String updatedBy) {
		this.updatedBy = updatedBy;
	}
	public String getAppId() {
		return appId;
	}
	public void setAppId(String appId) {
		this.appId = appId;
	}
	public Boolean getGlobal() {
		return global;
	}
	public void setGlobal(Boolean global) {
		this.global = global;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}
}